// test2.cpp - tests and demonstrates use of ncc_growable_array.h.
// NCC - Copyright (C) 2012 Willow Schlanger <wschlanger@gmail.com>
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list
//    of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
//    of conditions and the following disclaimer in the documentation and/or other materials
//    provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "../util/ncc_util.h"

#include <stdexcept>
#include <iostream>
#include <cstdio>

namespace ncc = NetwideCompilerCollection;

int main()
{
	using namespace std;
	
	ncc::growable_array<char> stk;
	
	stk.begin();
	stk.end();
	stk.clear();
	
	for(int i = 0; i < 300; ++i)
		stk.push_back('a' + (i % 26));
	stk.push_back('\n');
	for(int i = 0; i < 300; ++i)
		stk.push_back('b');
	stk.push_back('\0');
	stk.push_back('@');
	
	stk.back();
	stk.front();
	stk.pop_back();
	
	stk.begin() += 0;
	stk.begin() -= 0;
	++stk.begin();
	--stk.begin();
	stk.begin() + 0;
	stk.begin() - 0;
	stk.end() - stk.begin();
	stk.begin() == stk.end();
	stk.begin() != stk.end();

	stk.truncate(301);
	
	for(ncc::growable_array_iter<char> i = stk.begin(); i != stk.end(); ++i)
	{
		std::cout << *i << std::flush;
	}
	std::cout << std::endl;
	
	std::cout << ((stk.begin() + 123) - stk.begin()) << std::endl;
	
	/*ncc::NccAdvancedStack<char> stk(3);
	stk.push('a');
	stk.push('b');
	stk.push('c');

	stk.push('d');
	stk.push('e');
	stk.push('f');
	stk.push('g');
	stk.push('h');
	stk.push('i');

	stk.push('j');
	
	std::cout << "[" << std::flush;
	for(ncc::NccAdvancedStackIterator<char> i = stk.begin(); i != stk.end(); ++i)
	{
		std::cout << *i << std::flush;
	}
	std::cout << "]" << std::endl;*/
	
	return 0;
}
